package com.basic.bio.threadpool;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description:
 * @Date: 2024-03-28 14:18
 * @Author: wz
 **/
public class Server {

    public static void main(String[] args) {
        ThreadPoolExecutor poolExecutor = new ThreadPoolExecutor(2, 3, 200, TimeUnit.SECONDS, new LinkedBlockingDeque<>());
        try {
            ServerSocket serverSocket = new ServerSocket(9090);
            while (true){
                Socket socket = serverSocket.accept();
                poolExecutor.execute(new SocketThreadPool(socket));
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
